package cn.edu.sjtu.stap.sdg.builder.test;

public aspect ShipLog {
    private String Ship.flag = "Red";

    private boolean Ship.checkCaptain ()  {
       boolean result = false;
       if (getCaptain ()  =="Depp")  
         result = true; 
         return result; 
    }

    pointcut log(Ship ship, String spaceName) : execution (void explore (String) )  &&args (spaceName) &&target (ship) ;

    before() : execution (void setCaptain (String) ) {
        System.out.println("The Captain will be changed.");
    }


    after(Ship ship, String spaceName) : log (ship, spaceName) {
        System.out.println("finish exploring " + spaceName);
        if ((ship.flag == "Red") && ship.checkCaptain())
            Utils.sendMessage(spaceName);
    }
}
